import { ApiProperty } from '@midwayjs/swagger';
import { Rule, RuleType } from '@midwayjs/validate';

enum Status {
  Disabled = 0,
  Activated = 1,
}
export class UserDTO {
  @ApiProperty({
    description: 'id',
  })
  @Rule(RuleType.allow(null))
  id: number;

  @ApiProperty({
    description: '用户名',
    example: 'admin',
  })
  @Rule(RuleType.string().alphanum().min(3).max(30).required())
  username: string;

  @ApiProperty({
    description: '密码',
    example: '123456',
  })
  @Rule(RuleType.string().pattern(new RegExp('^[a-zA-Z0-9]{3,30}$')).required())
  password: string;

  @ApiProperty({
    description: '昵称',
    example: 'admin',
  })
  @Rule(RuleType.allow(null))
  nickname?: string;

  @ApiProperty({
    description: '手机号',
  })
  @Rule(RuleType.allow(null))
  phone?: string;

  @ApiProperty({
    description: '头像',
    example: '',
  })
  @Rule(RuleType.allow(null))
  avatar?: string;

  @ApiProperty({
    description: '状态',
    enum: [0, 1],
    example: 1,
  })
  @Rule(RuleType.allow(null))
  status: Status;
}
